package main

import (
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"gorm.io/gorm/schema"
	"shop/inventor-srv/model"
)

func main() {

	//dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=Local",
	//	"root", 123456, "127.0.0.1", "3306", "goods")
	//fmt.Println(dsn, "dsc")

	dsn := "root:123456@tcp(127.0.0.1:3306)/goods?charset=utf8mb4&parseTime=True&loc=Local"

	db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{
		NamingStrategy: schema.NamingStrategy{
			SingularTable: true,
		},
	})
	if err != nil {
		panic(err)
	}
	db.AutoMigrate(
		&model.Invertory{},
		//&model.InvertoryHistory{},
	)
}
